{{extend 'layout.html'}}

<div class="module">				
	<div class="module-body">						
		{{for row in rows:}}
			<div class="media stream">
				<a class="media-avatar medium pull-left" href="#">
					<img src="{{=URL('default', 'download', args=row.test.thumbnail)}}" />
				</a>
				<div class="media-body">
					<div class="stream-headline">
						<h5 class="stream-author">										
	                        {{for auth_user in db(db.auth_user.id.belongs(row.sfide.auth_user_id)).select():}}
	                        	<tr><td><a href={{=URL("default", "profilo", vars={"idutente":auth_user.id})}}>{{="%s %s"%(auth_user.first_name, auth_user.last_name)}}</a>-></td></tr>
	                        {{pass}}
						</h5>
						<div class="stream-text">
							<b>{{=row.test.test}}</b><br />
							{{=XML(row.test.descrizione)}}
						</div>
					</div>							
					<div class="stream-options">
						{{row_candidatura = db((db.candidatura.sfida_id==row.sfide.id)&(db.candidatura.auth_user_id==auth.user_id)).select().first()}}
						{{if row_candidatura:}}
	                        <a class="btn btn-small" href={{=URL('sfide', 'visualizza_candidatura', vars={'candidatura_id':row_candidatura.id})}}>
	                        	<i class="icon-cog shaded"></i>
	                            {{=T('Visualizza candidatura')}}
	                        </a>
						{{else:}}
	                        <a class="btn btn-small" href={{=URL('sfide', 'invia_candidatura', vars={'sfida_id':row.sfide.id})}}>
	                        	<i class="icon-cog shaded"></i>
	                            {{=T('Invia candidatura')}}
	                        </a>
	                        
							<button class="btn btn-small" onclick="if (confirm('Sei sicuro?')){ajax('{{=URL('sfide', 'rifiutaSfida', vars={'sfida_id':row.sfide.id})}}',[], null);jQuery(this).parent().parent().parent().hide();}">
								<i class="icon-remove-circle shaded"></i>
								{{=T('Rifiuta sfida')}}
							</button>	                        
	                        
	                        
	                        
						{{pass}}
					</div>
				</div>
			</div>
		{{pass}}
	</div>
</div>